Skip to content

feat(personality): add MBTI type + 8 cognitive functions - #16

Merged
ClaudiaFang merged 2 commits into
masterfrom
worktree-personality-mbti-cognitive-functions
Jul 21, 2026
Merged

feat(personality): add MBTI type + 8 cognitive functions#16
ClaudiaFang merged 2 commits into
masterfrom
worktree-personality-mbti-cognitive-functions

Conversation

@ClaudiaFang

Copy link
Copy Markdown
Member

Summary

  • Adds the 8 Jungian cognitive functions (Ni/Ne/Si/Se/Ti/Te/Fi/Fe) to the deterministic personality-scoring model, derived from the existing 8 effective-pattern categories (mean confidence per category, same aggregation style as the existing Craft trait).
  • Derives a 4-letter MBTI type + full function stack from the 8 function scores using the standard 16-type Jungian stack table (dominant/auxiliary/tertiary/inferior), fully deterministic with a documented, stable tie-break.
  • PersonalityProfile.profileVersion bumped to 2; PERSONALITY_ANALYSIS_VERSION bumped to 2.0.0. No DB migration needed — personality_snapshots.results_json is an opaque JSON blob.
  • New dashboard components: CognitiveFunctionRadarChart (8-axis radar, mirrors PersonalityRadarChart) and MbtiCard (type, confidence, function stack), wired into PersonalityPage.
  • Server Zod/OpenAPI schemas (server/src/schemas/personality.ts) updated to match.
  • LLM archetype prompt intentionally left untouched — every number in this feature stays deterministic, the LLM only ever produces prose.

Test plan

  • cd cli && pnpm test — 914/914 passing, including new coverage for all 8 function scores, MBTI derivation (INTJ/INFJ/ESFP/ESTP fixtures), the <2-signal null case, and tie-break determinism.
  • pnpm build from repo root — zero TypeScript errors across cli/server/dashboard.
  • pnpm test from repo root — cli 914, server 655, dashboard 15, all passing.
  • Manual dashboard smoke test (not yet done live in a browser — JSX reviewed by hand for the new components)

🤖 Generated with Claude Code

ClaudiaFang and others added 2 commits July 21, 2026 13:04
Extends the deterministic Personality Analysis profile with a second layer
scored from the same effective-pattern facets: one score per Jungian
cognitive function (Ni/Ne/Si/Se/Ti/Te/Fi/Fe), mapped 1:1 from the 8
effective-pattern categories, plus a pure deriveMbti() that picks a 4-letter
type from the standard 16-type function-stack table using dominant/auxiliary
scores with a documented, deterministic tie-break.

PersonalityProfile.profileVersion bumps to 2 (cognitiveFunctions + mbti
fields); PERSONALITY_ANALYSIS_VERSION bumps to 2.0.0. No SQLite schema
change — personality_snapshots.results_json is an opaque JSON blob and old
cached rows are read via JSON.parse(...) as PersonalityProfile, not runtime-
validated, so profileVersion 1 stays in the type union for those.

Every number here stays deterministic and LLM-free, same as the rest of
this module — the archetype narrative continues to be the only LLM-touched
field.
Extends the archetype-generation LLM call (POST /api/personality/generate)
to also return a ranked top-5 MBTI type guess list with reasoning, grounded
in the 8 cognitive function scores and 4 traits — a softer, LLM-authored
companion view alongside the existing deterministic single-type derivation.
`likelihood` is a deliberate, documented exception to this feature's "LLM
never produces a number" rule, since ranking requires one. Every field is
re-validated/clamped server-side (type must be one of the 16 valid codes,
deduped, capped at 5, likelihood clamped to 0-100, rank reassigned from
array order).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ClaudiaFang

Copy link
Copy Markdown
Member Author

Summary

  • Adds the 8 Jungian cognitive functions (Ni/Ne/Si/Se/Ti/Te/Fi/Fe) to the deterministic personality-scoring model, derived from the existing 8 effective-pattern categories (mean confidence per category, same aggregation style as the existing Craft trait).
  • Derives a 4-letter MBTI type + full function stack from the 8 function scores using the standard 16-type Jungian stack table (dominant/auxiliary/tertiary/inferior), fully deterministic with a documented, stable tie-break.
  • New: extends the existing archetype-generation LLM call to also return a ranked top-5 MBTI type guess list with reasoning (mbti.topCandidates), grounded in the 8 function scores + 4 traits — a softer, LLM-authored companion view alongside the deterministic single type. likelihood is a deliberate, documented exception to this feature's "LLM never produces a number" rule; every field is re-validated/clamped server-side (type restricted to the 16 valid codes, deduped, capped at 5, likelihood clamped 0-100, rank reassigned from array order — nothing from the LLM response is trusted as-is).
  • PersonalityProfile.profileVersion bumped to 2; PERSONALITY_ANALYSIS_VERSION bumped to 2.0.0. No DB migration needed — personality_snapshots.results_json is an opaque JSON blob.
  • New dashboard components: CognitiveFunctionRadarChart (8-axis radar, mirrors PersonalityRadarChart) and MbtiCard (type, confidence, function stack, and — once generated — the ranked top-5 LLM guesses with likelihood bars and reasoning), wired into PersonalityPage.
  • Server Zod/OpenAPI schemas (server/src/schemas/personality.ts) updated to match, including the new MBTICandidateSchema.

Test plan

  • cd cli && pnpm test — 914/914 passing, including coverage for all 8 function scores, MBTI derivation (INTJ/INFJ/ESFP/ESTP fixtures), the <2-signal null case, and tie-break determinism.
  • pnpm build from repo root — zero TypeScript errors across cli/server/dashboard.
  • pnpm test from repo root — cli 914, server 655, dashboard 15, all passing (re-verified after the topCandidates addition).
  • Manual dashboard smoke test of the Generate flow with a live LLM call (not yet done live in a browser — JSX and sanitization logic reviewed by hand)

🤖 Generated with Claude Code

@ClaudiaFang
ClaudiaFang marked this pull request as ready for review July 21, 2026 13:20
@ClaudiaFang
ClaudiaFang merged commit 421afd7 into master Jul 21, 2026
1 check passed
@ClaudiaFang
ClaudiaFang deleted the worktree-personality-mbti-cognitive-functions branch July 21, 2026 13:20
ClaudiaFang pushed a commit that referenced this pull request Jul 23, 2026
chore: pre-launch open-source cleanup
ClaudiaFang added a commit that referenced this pull request Jul 23, 2026
…gnitive-functions

feat(personality): add MBTI type + 8 cognitive functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant